﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiMaterialMap : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiMaterialMap(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiMaterialMap obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiMaterialMap()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiMaterialMap(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public static OdGiMaterialMap kNull
		{
			get
			{
				IntPtr intPtr = GlobalsPINVOKE.OdGiMaterialMap_kNull_get();
				OdGiMaterialMap result = (intPtr == IntPtr.Zero) ? null : new OdGiMaterialMap(intPtr, false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
		}

		public OdGiMaterialMap() : this(GlobalsPINVOKE.new_OdGiMaterialMap(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setSource(OdGiMaterialMap.Source source)
		{
			GlobalsPINVOKE.OdGiMaterialMap_setSource(this.swigCPtr, (int)source);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setSourceFileName(string filename)
		{
			GlobalsPINVOKE.OdGiMaterialMap_setSourceFileName(this.swigCPtr, filename);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setBlendFactor(double blendFactor)
		{
			GlobalsPINVOKE.OdGiMaterialMap_setBlendFactor(this.swigCPtr, blendFactor);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setTexture(OdGiMaterialTexture pTexture)
		{
			GlobalsPINVOKE.OdGiMaterialMap_setTexture(this.swigCPtr, OdGiMaterialTexture.getCPtr(pTexture));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGiMapper mapper()
		{
			OdGiMapper result = new OdGiMapper(GlobalsPINVOKE.OdGiMaterialMap_mapper__SWIG_0(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiMaterialMap.Source source()
		{
			OdGiMaterialMap.Source result = (OdGiMaterialMap.Source)GlobalsPINVOKE.OdGiMaterialMap_source(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public string sourceFileName()
		{
			string result = GlobalsPINVOKE.OdGiMaterialMap_sourceFileName(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public double blendFactor()
		{
			double result = GlobalsPINVOKE.OdGiMaterialMap_blendFactor(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setMapper(OdGiMapper mapper)
		{
			GlobalsPINVOKE.OdGiMaterialMap_setMapper(this.swigCPtr, OdGiMapper.getCPtr(mapper));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGiMaterialTexture texture()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialMap_texture(this.swigCPtr);
			OdGiMaterialTexture result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsEqual(OdGiMaterialMap other)
		{
			bool result = GlobalsPINVOKE.OdGiMaterialMap_IsEqual(this.swigCPtr, OdGiMaterialMap.getCPtr(other));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsNotEqual(OdGiMaterialMap other)
		{
			bool result = GlobalsPINVOKE.OdGiMaterialMap_IsNotEqual(this.swigCPtr, OdGiMaterialMap.getCPtr(other));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGiMaterialMap Assign(OdGiMaterialMap mmap)
		{
			OdGiMaterialMap result = new OdGiMaterialMap(GlobalsPINVOKE.OdGiMaterialMap_Assign(this.swigCPtr, OdGiMaterialMap.getCPtr(mmap)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		public enum Source
		{
			kScene,
			kFile,
			kProcedural
		}
	}
}
